package com.bai;

import com.alipay.api.AlipayApiException;
import com.alipay.api.internal.util.AlipaySignature;

public class Sign {

    private static final String responseData = "KdIVmQMrBZ3kF85nqtawww12UrepqYeXb7enyVNETMN928ibNy81O9sZ/9PGXcsvGr6QhDiBCH0DZ/OL2fmAg7vWhe9/Gn1dBERUQeckQ3pA+eAGo8a+3P6Jqucvf2nb2GdPPyvd2fheTTUhDE7JyDgu72uITWbKUv0G+5YMFWU=";
    private static final String sign = "htQegJZQTrkJcj4+dZMDaK2BHU7vLysm+OXoMYwbqKQumLkzSNlOqs3DsayBiUkZpYBl0/0WasYfCCuR+/z9kHf1YAmJ2EeEBSBlMfoqMUlJLq0JphJB/xXwWO7yBLQmKm6etN6tqCujFfPR3RSPMJWWfWqZkzvQnXewZMFQC5bjIhTeS0qCUtUPkGjgmbSnhwf5BLAVasoxiqHFrmkjtQ26OahRBZN9xaKZIabVFM4QbbkbM0YAaPkm908DZwV+ZO3+t0JnX1HJkd+JiKeb227M+nkdO7N/xvcPz8ePtsN36HiBMpY/sGCb5ZJDfC/eNsFfn3pxI1DDTRBLrxnelA==";

    private static final String alipayPublicKey  = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAiSAM5juc9xpSmlo5Gg3BG1j1pPFCi60riR4Msb93umDBOlJdo2GibLQ2wc1jyg8FRWFI4ndadEESzFhimaYORSZbnb37gX7bvvirGW8KdNV28p5LD3ro/Q4e0ZEr1s67RjdD6vbV7OQ6UBYr2t89KxVEC6Rv/TpYi47WcsTOBZkxltPDq0G83UDTfKNZ0YlXJLVulxpjBUOWzfxow4JRpLqCWeQ4NzofYuJMwvK7zIeFeQEq4QNQXtnzQU3Vhz6/FIfHv9DnD5nArbZrIrzJDmgKBSrvoZHzCw7YteXoUGQgwnvD5PIonLWl3zg3fKzFs93AWQFY6fkSTvL1evu77wIDAQAB";

    private static final String appPrivateKey =  "MIIEuwIBADANBgkqhkiG9w0BAQEFAASCBKUwggShAgEAAoIBAQC9Gke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/CsEYYaBLn1ZCpS3Yrk6Debkwiit8j5vcrAwaoGn3pS4NBaxahoYdLO1Da1VRqupAjfu4dGJdI1QHYfV0uEDpT6E7ZS2fNrBbTMRmH50jUqWP6Wzmad3lECgYAFBB9sCnt5UzCFV0D17nQD/1WXV4f1/uK9CVCCdOaIslvaCihgW1UuGh5fG1kOdMnhIowDKbiM/a6yZHz305mC5wxaP6u5yuGn3t0Wayf53VWCxciYUyRHx4XFqGaRhw86HnEFmZ0AAfRb5YvP8INJV0pBe9NL9stDde3F7tB6VQKBgAm8VcQ5laz+XGfJQoFWIMK+BDBXvhTfjBtQv09Hpc1AAxG4/j0DhTwBu2XaT8g7isqZGrjzKS2HvoELE7WTXiH+78XHfBZ3WJ+7/JYsEhKD5hWhdzK5qYd7cWyHsh1HShkRRpJkFIe5ts7sZs72e5Oz7Fu7OzDWpxlTBosI6r/3";


    public static void main(String[] args) throws AlipayApiException {

        // 解密 response（需要你的小程序私钥）
        String decryptedData = AlipaySignature.rsaDecrypt(responseData, appPrivateKey, "UTF-8");
        System.out.println("解密后的内容：" + decryptedData);

//// 用支付宝公钥验证签名（可选）
//        boolean isVerified = AlipaySignature.rsaCheck(responseData, sign, alipayPublicKey, "UTF-8", "RSA2");
//
//        if (isVerified) {
//
//        } else {
//            System.out.println("签名验证失败");
//        }
    }
}
